#
# Copyright 2021 The Modelbox Project Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

 
cmake_minimum_required(VERSION 3.10)
 
set(UNIT_GRAPHCONF "graphconf")
set(UNIT_NAME "graphviz")
 
project(modelbox-${UNIT_GRAPHCONF}-${UNIT_NAME})
 
file(GLOB_RECURSE UNIT_SOURCE *.cpp *.cc *.c)
group_source_test_files(MODELBOX_UNIT_GRAPHCONF_GRAPHVIZ_SOURCE MODELBOX_UNIT_TEST_SOURCE "_test.c*" ${UNIT_SOURCE})
 
include_directories(${CMAKE_CURRENT_LIST_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${LIBMODELBOX_INCLUDE})
include_directories(${LIBMODELBOX_BASE_INCLUDE})
 
set(LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED libmodelbox-${UNIT_GRAPHCONF}-${UNIT_NAME}-shared)
set(LIBMODELBOX_GRAPHCONF_GRAPHVIZ_INCLUDE ${CMAKE_CURRENT_LIST_DIR})
 
add_library(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} SHARED ${MODELBOX_UNIT_GRAPHCONF_GRAPHVIZ_SOURCE})
 
set_target_properties(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} PROPERTIES 
    SOVERSION ${MODELBOX_VERSION_MAJOR}
    VERSION ${MODELBOX_VERSION_MAJOR}.${MODELBOX_VERSION_MINOR}.${MODELBOX_VERSION_PATCH}
)
 
target_link_libraries(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} pthread)
target_link_libraries(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} rt)
target_link_libraries(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} dl)
target_link_libraries(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} cgraph)
target_link_libraries(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} ${LIBMODELBOX_SHARED})
 
set_target_properties(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} PROPERTIES OUTPUT_NAME "modelbox-${UNIT_GRAPHCONF}-${UNIT_NAME}")
 
install(TARGETS ${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED}
    COMPONENT graph-graphviz
    RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
    OPTIONAL
    )
 
set(LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED ${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED} CACHE INTERNAL "")
set(LIBMODELBOX_GRAPHCONF_GRAPHVIZ_INCLUDE ${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_INCLUDE} CACHE INTERNAL "")
set(LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SOURCES ${MODELBOX_UNIT_GRAPHCONF_GRAPHVIZ_SOURCE} CACHE INTERNAL "")

list(APPEND DRIVER_UNIT_TEST_SOURCE ${MODELBOX_UNIT_TEST_SOURCE})
list(APPEND DRIVER_UNIT_TEST_TARGET ${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED})
set(DRIVER_UNIT_TEST_SOURCE ${DRIVER_UNIT_TEST_SOURCE} CACHE INTERNAL "")
set(DRIVER_UNIT_TEST_TARGET ${DRIVER_UNIT_TEST_TARGET} CACHE INTERNAL "")
 
 